define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Searchpro_agent, GoAddress,$stateParams,GoDialog) {
		$scope.input = new Object();
		$scope.input.province = {id:0,name:"请选择省份"}; //省市区三级联动
		$scope.input.city = {id:0,name:"请选择城市"}; //省市区三级联动
		$scope.input.district = {id:0,name:"请选择区/县"}; //省市区三级联动
$scope.url = $stateParams.url;
$scope.datas = $stateParams.params;
console.log($scope.url);
console.log($scope.datas);
		//下拉侦听，目前只能省市区三级联动
		$scope.listen_province = function(data) {
			$scope.input.city = {id:0,name:"请选择城市"}; //省市区三级联动
		$scope.input.district = {id:0,name:"请选择区/县"}; //省市区三级联动
		};
		$scope.listen_city = function(data) {
			$scope.input.district = {id:0,name:"请选择区/县"}; //省市区三级联动
		};
		
		//定义绑定
		var items = new Array();
		var obj1 = { name: 'input.province' };
		var obj2 = { name: 'input.city' };
		var obj3 = { name: 'input.district' };
		items.push(obj1);
		items.push(obj2);
		items.push(obj3);
		GoAddress.init_load($scope, items);
		$scope.doSelectProvince = function(store){
			//id是值 name是显示
			GoDialog.showSelect("请选择省份",$scope.province_items,$scope.input.province,function(data){
				$scope.input.province = data;
			});
		}
		$scope.doSelectCity = function(store){
			//id是值 name是显示
			GoDialog.showSelect("请选择城市",$scope.city_items,$scope.input.city,function(data){
				$scope.input.city = data;
			});
		}
		$scope.doSelectDistrict = function(store){
			//id是值 name是显示
			GoDialog.showSelect("请选择区/县",$scope.district_items,$scope.input.district,function(data){
				$scope.input.district = data;
			});
		}

	}

	controller.$inject = ['$scope', 'Searchpro_agent', 'GoAddress','$stateParams','GoDialog'];
	
	return app.registerController("searchpro_agentctrl",controller);
});